<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Module: layers</title>

<!--
    <script src="http://shjs.sourceforge.net/sh_main.min.js"> </script>
    <script src="http://shjs.sourceforge.net/lang/sh_javascript.min.js"> </script>
-->
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/node-dark.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>

<body>

<div id="main">
    
    <h1 class="page-title">Module: layers</h1>
    
    



<section>
    
<header>
    <h2>
    layers
    </h2>
    
</header>  

<article>
    <div class="container-overview">
    
    
    
        
            <div class="description"><p>The <code>fwlib/layers</code> module includes a number of utility functions and classes
that make it easier to inspect and manipulate the layers in a Fireworks
document.  The native layers API was sufficient back before sub-layers were
introduced, but it's now much harder to understand and manipulate the layer
structure.</p>

<p>For instance, if an element is selected and you want to move the top-level
layer that contains that element up or down in the stack, how do you find
the top-level layer?  You have to call <code>dom.getParentLayerNum(dom.currentLayerNum)</code>,
check if the if result is <code>-1</code>, and if not, call it again with the result,
until you get a <code>-1</code>.  There's also no easy way to figure out which layer is
directly above or below another one.  The classes and functions in this
module simplify this process.</p></div>
        
        
        
<dl class="details">
    
        
	
	
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	<dt class="tag-source">Source:</dt>
	<dd class="tag-source"><ul class="dummy"><li>lib/fwlib/layers.js, line 5</li></ul></dd>
	
    
    
	
	
	
	
</dl>

        
        
    
    </div>
    
    
    
    
    
    
    
    
        <h3 class="subsection-title">Classes</h3>
        
        <dl>
            <dt><a href="module-layers.Layer.html">Layer</a></dt>
            <dd></dd>
        
            <dt><a href="module-layers.LayerTree.html">LayerTree</a></dt>
            <dd></dd>
        </dl>
    
    
    
    
    
    
    
        <h3 class="subsection-title">Methods</h3>
        
        <dl>
            
<dt>
    <h4 class="name" id="layers.alertLayers"><span class="type-signature">&lt;static> </span>layers.alertLayers</h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        <p>Displays a textual representation of the layer structure of a document in
an alert dialog.  This can help with debugging a command that modifies
the layer structure, so you can get a snapshot of the layers at different
points in the command.</p>

<p>Each line in the representation shows the layer index and the name of
the layer.  The indentation of the line indicates the parent/child
relationships of the layers, simliar to how they're shown in the <em>Layers</em>
panel.</p>

<pre><code>5: Web Layer
2: Layer 3
    3: Layer 5
        4: Layer 4
0: Layer 1
    1: Layer 2
</code></pre>
    </div>
    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		<th>Argument</th>
		
		
		
		<th>Default</th>
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>inDom</code></td>
            
            
            <td class="type">
            
                        DOM
                        
                    
            </td>
            
            
                <td class="attributes">
                
                    &lt;optional><br>
                
                    
                
                </td>
            
            
            
                <td class="default">
                
                    currentDOM
                
                </td>
            
            
            <td class="description last"><p>The document whose layers should be
shown.  This defaults to the current document if not specified.</p></td>
        </tr>
	
	
	
        <tr>
            
                <td class="name"><code>inJustReturnOutput</code></td>
            
            
            <td class="type">
            
                        Boolean
                        
                    
            </td>
            
            
                <td class="attributes">
                
                    &lt;optional><br>
                
                    
                
                </td>
            
            
            
                <td class="default">
                
                    false
                
                </td>
            
            
            <td class="description last"><p>Pass true to suppress the
<code>alert()</code> dialog and just return the layer structure as a string.</p></td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
	
	
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	<dt class="tag-source">Source:</dt>
	<dd class="tag-source"><ul class="dummy"><li>lib/fwlib/layers.js, line 1326</li></ul></dd>
	
    
    
	
	
	
	
</dl>

    
    
    
    
    
    
    <h5>Returns:</h5>
    
            
<div class="param-desc">
    <p>If <code>inJustReturnOutput</code> is true, a string representation
of the document's layer stack.  Otherwise, nothing.</p>
</div>




<dl>
	<dt>
		Type
	</dt>
	<dd>
		
		<span class="param-type">String</span> 
		
	</dd>
</dl>

        
    
    
</dd>

        
            
<dt>
    <h4 class="name" id="layers.copyLayer"><span class="type-signature">&lt;static> </span>layers.copyLayer</h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        <p>Copies the elements on a layer from one document to another.  This
method is provisional and may not work in all cases.</p>
    </div>
    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		<th>Argument</th>
		
		
		
		<th>Default</th>
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>inLayer</code></td>
            
            
            <td class="type">
            
                        Layer
                        
                    
            </td>
            
            
                <td class="attributes">
                
                    
                
                </td>
            
            
            
                <td class="default">
                
                </td>
            
            
            <td class="description last"><p>The <code>Layer</code> instance to copy.</p></td>
        </tr>
	
	
	
        <tr>
            
                <td class="name"><code>inTargetDom</code></td>
            
            
            <td class="type">
            
                        DOM
                        
                    
            </td>
            
            
                <td class="attributes">
                
                    
                
                </td>
            
            
            
                <td class="default">
                
                </td>
            
            
            <td class="description last"><p>The document to copy the layer's elements to.</p></td>
        </tr>
	
	
	
        <tr>
            
                <td class="name"><code>inSourceDom</code></td>
            
            
            <td class="type">
            
                        DOM
                        
                    
            </td>
            
            
                <td class="attributes">
                
                    &lt;optional><br>
                
                    
                
                </td>
            
            
            
                <td class="default">
                
                    currentDOM
                
                </td>
            
            
            <td class="description last"><p>The document to copy the layer's
elements from.  If this isn't included, the current document is
used as the source.</p></td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
	
	
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	<dt class="tag-source">Source:</dt>
	<dd class="tag-source"><ul class="dummy"><li>lib/fwlib/layers.js, line 1047</li></ul></dd>
	
    
    
	
	
	
	
</dl>

    
    
    
    
    
    
    
    
</dd>

        
            
<dt>
    <h4 class="name" id="layers.copyLayerBetweenPages"><span class="type-signature">&lt;static> </span>layers.copyLayerBetweenPages</h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        <p>Copies the elements on a layer from one page to another in the same
document.  This method is provisional and may not work in all cases.</p>
    </div>
    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>inLayer</code></td>
            
            
            <td class="type">
            
                        Layer
                        
                    
            </td>
            
            
            
            
            
            <td class="description last"><p>The <code>Layer</code> instance to copy.</p></td>
        </tr>
	
	
	
        <tr>
            
                <td class="name"><code>inSourcePageIndex</code></td>
            
            
            <td class="type">
            
                        Number
                        
                    
            </td>
            
            
            
            
            
            <td class="description last"><p>The index of the page to copy from.</p></td>
        </tr>
	
	
	
        <tr>
            
                <td class="name"><code>inTargetPageIndex</code></td>
            
            
            <td class="type">
            
                        Number
                        
                    
            </td>
            
            
            
            
            
            <td class="description last"><p>The index of the page to copy to.</p></td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
	
	
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	<dt class="tag-source">Source:</dt>
	<dd class="tag-source"><ul class="dummy"><li>lib/fwlib/layers.js, line 1135</li></ul></dd>
	
    
    
	
	
	
	
	<dt class="tag-todo">To Do:</dt>
	<dd class="tag-todo">
        <ul>
            <li>Ensure that elements get copied to the appropriately named layer.</li>
        </ul>
	</dd>
	
</dl>

    
    
    
    
    
    
    
    
</dd>

        
            
<dt>
    <h4 class="name" id="layers.getLayerIndexByName"><span class="type-signature">&lt;static> </span>layers.getLayerIndexByName</h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        <p>Returns the index of the named layer.</p>
    </div>
    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		<th>Argument</th>
		
		
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>inLayerName</code></td>
            
            
            <td class="type">
            
                        String
                        
                    
            </td>
            
            
                <td class="attributes">
                
                    
                
                </td>
            
            
            
            
            <td class="description last"><p>The name of the index.</p></td>
        </tr>
	
	
	
        <tr>
            
                <td class="name"><code>inDom</code></td>
            
            
            <td class="type">
            
                        DOM
                        
                    
            </td>
            
            
                <td class="attributes">
                
                    &lt;optional><br>
                
                    
                
                </td>
            
            
            
            
            <td class="description last"><p>The document to look in to find the layer.  This
defaults to the current document if not specified.</p></td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
	
	
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	<dt class="tag-source">Source:</dt>
	<dd class="tag-source"><ul class="dummy"><li>lib/fwlib/layers.js, line 1229</li></ul></dd>
	
    
    
	
	
	
	
</dl>

    
    
    
    
    
    
    <h5>Returns:</h5>
    
            
<div class="param-desc">
    <p>The index of the layer in the Fireworks layers stack,
or <code>-1</code> if a layer with that name can't be found.</p>
</div>




<dl>
	<dt>
		Type
	</dt>
	<dd>
		
		<span class="param-type">Number</span> 
		
	</dd>
</dl>

        
    
    
</dd>

        
            
<dt>
    <h4 class="name" id="layers.getTopLayerAncestorIndex"><span class="type-signature">&lt;static> </span>layers.getTopLayerAncestorIndex</h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        <p>Returns the index of the top-level layer that contains the layer
specified by <code>inLayerIndex</code>.</p>
    </div>
    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		<th>Argument</th>
		
		
		
		<th>Default</th>
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>inLayerIndex</code></td>
            
            
            <td class="type">
            
                        Number
                        
                    
            </td>
            
            
                <td class="attributes">
                
                    
                
                </td>
            
            
            
                <td class="default">
                
                </td>
            
            
            <td class="description last"><p>A layer index.</p></td>
        </tr>
	
	
	
        <tr>
            
                <td class="name"><code>inDom</code></td>
            
            
            <td class="type">
            
                        DOM
                        
                    
            </td>
            
            
                <td class="attributes">
                
                    &lt;optional><br>
                
                    
                
                </td>
            
            
            
                <td class="default">
                
                    currentDOM
                
                </td>
            
            
            <td class="description last"><p>The document to look in to find the
layer.  This defaults to the current document if not specified.</p></td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
	
	
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	<dt class="tag-source">Source:</dt>
	<dd class="tag-source"><ul class="dummy"><li>lib/fwlib/layers.js, line 1251</li></ul></dd>
	
    
    
	
	
	
	
</dl>

    
    
    
    
    
    
    <h5>Returns:</h5>
    
            
<div class="param-desc">
    <p>The index of the top-level layer in the Fireworks
layers stack that contains the layer specified by <code>inLayerIndex</code>.</p>
</div>




<dl>
	<dt>
		Type
	</dt>
	<dd>
		
		<span class="param-type">Number</span> 
		
	</dd>
</dl>

        
    
    
</dd>

        
            
<dt>
    <h4 class="name" id="layers.getTopLayerIndexes"><span class="type-signature">&lt;static> </span>layers.getTopLayerIndexes</h4>
    
    
</dt>
<dd>
    
    
    <div class="description">
        <p>Returns an array of the indexes that correspond to the top-level layers
in the document.</p>
    </div>
    
    
    
    
    
        <h5>Parameters:</h5>
        

<table class="params">
    <thead>
	<tr>
		
		<th>Name</th>
		
		
		<th>Type</th>
		
		
		<th>Argument</th>
		
		
		
		<th>Default</th>
		
		
		<th class="last">Description</th>
	</tr>
	</thead>
	
	<tbody>
	
	
        <tr>
            
                <td class="name"><code>inDom</code></td>
            
            
            <td class="type">
            
                        DOM
                        
                    
            </td>
            
            
                <td class="attributes">
                
                    &lt;optional><br>
                
                    
                
                </td>
            
            
            
                <td class="default">
                
                    currentDOM
                
                </td>
            
            
            <td class="description last"><p>The document containing the layers, or
the current document if not specified.</p></td>
        </tr>
	
	
	</tbody>
</table>
    
    
    
<dl class="details">
    
        
	
	
	

	
	
	
	
	
	
	
	
	
	
	
	
	
	<dt class="tag-source">Source:</dt>
	<dd class="tag-source"><ul class="dummy"><li>lib/fwlib/layers.js, line 1276</li></ul></dd>
	
    
    
	
	
	
	
</dl>

    
    
    
    
    
    
    <h5>Returns:</h5>
    
            
<div class="param-desc">
    <p>All of the indexes of the top-level layers in the document.</p>
</div>




<dl>
	<dt>
		Type
	</dt>
	<dd>
		
		<span class="param-type">Array</span> 
		
	</dd>
</dl>

        
    
    
</dd>

        </dl>
    
    
    
    
    
</article>

</section>  




</div>

<nav>
    <h2><a href="index.html">Index</a></h2><h3>Modules</h3><ul><li><a href="module-DomStorage.html">DomStorage</a></li><li><a href="module-files.html">files</a></li><li><a href="module-fonts.html">fonts</a></li><li><a href="module-layers.html">layers</a></li><li><a href="module-prefs.html">prefs</a></li><li><a href="module-underscore.html">underscore</a></li></ul><h3>Classes</h3><ul><li><a href="a321565296.html">DomStorage</a></li><li><a href="module-layers.Layer.html">Layer</a></li><li><a href="module-layers.LayerTree.html">LayerTree</a></li><li><a href="module-prefs.PrefsStorage.html">PrefsStorage</a></li><li><a href="_.html">_</a></li></ul>
</nav>

<br clear="both">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3</a> on Mon Jul 08 2013 09:13:10 GMT-0700 (PDT)
</footer>

<script> sh_highlightDocument(); </script>
</body>
</html>
